import * as Router from 'koa-router';
import * as bodyParser from 'koa-bodyparser';
import { CleanMessages, GetImage, GetMessages, QueryConvs, UploadImage, WorkflowRun, WorkflowStop } from './apiCtrl';

// 创建路由实例
const router = new Router({
    prefix: '/coeus_coder/api',
});

// 使用koa-bodyparser中间件解析请求体
router.use(bodyParser());
router.get("/version", async (ctx) => {
    ctx.body = {
        version: "0.0.1"
    }
})

router.post("/workflow/run/:workflowId", WorkflowRun)
router.post("/workflow/stop/:workflowId", WorkflowStop)

router.get("/queryConvs", QueryConvs)
router.get("/convs/:convId/messages", GetMessages)
router.post("/convs/:convId/messages/clean", CleanMessages)

router.post('/upload/image', UploadImage);
router.get('/image/:filename', GetImage)

export default router;